package com.niit.web.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.bean.User;
import com.niit.service.UserService;
import com.niit.service.impl.UserServiceImpl;
import com.niit.utils.WebKit;

@WebServlet("/RegisterByMobController")
public class RegisterByMobController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		User user = WebKit.request2Bean(request, User.class);
		user.setValidation(true);
		UserService us = new UserServiceImpl();
		if(us.add(user)>0){
			response.getOutputStream().write("s".getBytes());
		}else{
			response.getOutputStream().write("f".getBytes());
		}
		
	}

}
